home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech's Sprocket™ / SprocketGX / Lib / SplashWindow.cp < prev    next >
Encoding:
Text File  |  1994-10-17  |  1.5 KB  |  62 lines  |  [TEXT/MMCC]

  1. /*
  2.     File:        SplashWindow.cp
  3.  
  4.     Contains:    a simple splash screen window
  5.                 
  6.     Written by: Dave Falkenburg
  7.     
  8.     Copyright:    © 1993-94 by Dave Falkenburg, all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.     
  12.     To Do:        Add tools to the palette
  13.  */
  14.  
  15. #include <ToolUtils.h>
  16. #include <Resources.h>
  17. #include "AppLib.h"
  18. #include "SplashWindow.h"
  19.  
  20.  
  21. TSplashWindow::TSplashWindow()
  22. {
  23.     this->CreateWindow(kNormalWindow);
  24. }
  25.  
  26. TSplashWindow::~TSplashWindow()
  27. {
  28.     this->Close();
  29. }
  30.  
  31. WindowPtr TSplashWindow::MakeNewWindow(WindowPtr behindWindow)
  32. {
  33.     CSavePort  aSavePort(nil);
  34.     PicHandle    splashPicture = GetPicture(kSplashPictureID);
  35.     WindowPtr    splashWindow;
  36.     
  37.     if (splashPicture)
  38.     {
  39.         Rect    r = (*splashPicture)->picFrame;
  40.         Rect    windowRect;
  41.         
  42.         //    normalize the rectangle
  43.         OffsetRect(&r,-r.left,-r.top);
  44.  
  45.         windowRect = r;
  46.         //    center it on the main screen
  47.         OffsetRect(&windowRect,((qd.screenBits.bounds.right-r.right) >> 1),((qd.screenBits.bounds.bottom-r.bottom) >> 1));
  48.         
  49.         splashWindow = NewColorOrBlackAndWhiteWindow(nil,&windowRect,"\p",false,dBoxProc,behindWindow,false,(long) this);
  50.  
  51.         DetachResource((Handle) splashPicture);        // need to do so we don’t botch the resource map after closing
  52.         SetWindowPic(splashWindow,splashPicture);    // in case an Alert comes up
  53.         ShowWindow(splashWindow);
  54.  
  55.         SetPort(splashWindow);
  56.         BeginUpdate(splashWindow);                    //    avoid a flashing update event later
  57.             DrawPicture(splashPicture,&r);
  58.         EndUpdate(splashWindow);                    //    avoid a flashing update event later
  59.     }
  60.     return splashWindow;
  61. }
  62.